package news.dao;

import news.pojo.User;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class UserDao {
    /**
     * 使用用户名和密码进行查询用户
     *
     * @param account
     * @param password
     * @return 信息正确返回用户信息 错则返回null
     * @throws SQLException
     */
    public User login(String account, String password) throws SQLException {
        QueryRunner queryRunner = DBTool.getQueryRunner();
        String sql = "select * from users where account = ? and password = ?";
        return queryRunner.query(sql, new BeanHandler<User>(User.class), account, password);
    }
}
